﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using  System.Threading;
using DTOQLDV;
using BUSQLDV;
using System.Configuration;

namespace QLDV_DA
{
    public partial class frmsplash : DevExpress.XtraEditors.XtraForm
    {
        private static Thread _splashThread;    
        private static frmsplash _splashForm;   
        public frmsplash()
        {
            InitializeComponent();
        }
        public static void ShowSplash()
        {
            if (_splashThread == null)
            {
                // show the form in a new thread            
                _splashThread = new Thread(new ThreadStart(DoShowSplash));              
                _splashThread.IsBackground = true;               
                _splashThread.Start();                
            }
        }

        // Called by the thread    
        private static void DoShowSplash()
        {
            //CaiDatThamSo();
            if (_splashForm == null)
            {
                _splashForm = new frmsplash();
                _splashForm.StartPosition = FormStartPosition.CenterScreen;
                _splashForm.TopMost = true;              
            }           
            // create a new message pump on this thread (started from ShowSplash)        
            Application.Run(_splashForm);           
        }
        // Close the splash (Loading...) screen    
        public static void CloseSplash()
        {
            // Need to call on the thread that launched this splash        
            if (_splashForm.InvokeRequired)
                _splashForm.Invoke(new MethodInvoker(CloseSplash));
            else
                Application.ExitThread();
        }        
    }
}